/**
 *  Copyright (C) 2013  Piotr Szczepa�ski
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
package edu.pw.elka.gtsna.graph_evaluators;

import java.util.Set;

import edu.pw.elka.gtsna.graph.Graph;
import edu.pw.elka.gtsna.graph_algorithms.FindComponents;

/**
 * @author Piotr Lech Szczepa�ski
 * @author P.Szczepanski@ii.pw.edu.pl 
 *
 */
public class LargestComponentEvaluator extends GraphEvaluator {

	
	FindComponents fc;
     
	/**
	 * @param graph
	 */
	public LargestComponentEvaluator(Graph graph) {
		super(graph);
		fc = new FindComponents(graph);
	}


	@Override
	public double evaluate() {
		
		double largestComponent = 0.0;
		fc.compute();
		
		for (Set<Integer> component: fc.getComponents()){
			if (component.size()> largestComponent)
				largestComponent=component.size();
		}
		
		return largestComponent;
		
	}
	

}
